package com.meusdrinks.persistence;

import java.util.List;

import br.gov.frameworkdemoiselle.stereotype.PersistenceController;
import br.gov.frameworkdemoiselle.template.JPACrud;

import com.meusdrinks.domain.Drink;
import com.meusdrinks.domain.IngredienteDrink;

@PersistenceController
public class DrinkDAO extends JPACrud<Drink, Long> {

	private static final long serialVersionUID = 1L;	
	
	public List<IngredienteDrink> findByDrink(Long idDrink){
		return getEntityManager().createQuery("SELECT ingDrink FROM IngredienteDrink ingDrink JOIN ingDrink.drink d WHERE d.id = :idDrink")
				.setParameter("idDrink", idDrink).getResultList();
	}

}
